From 622c978057eb874e904d96dc2f5d3fd192630ccf Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Thu, 19 May 2005 13:49:14 +0000 Subject: [PATCH] bitkeeper revision 1.1464 (428c995a_kOA184Gp70LrbrBFFfKTA) Mark all non-RAM pages as I/O holes in the frame_table. Signed-off-by: Keir Fraser --- xen/arch/x86/mm.c | 25 +++++++++++++------------ xen/arch/x86/setup.c | 4 ++-- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index cd96fec083..f27508a40d 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -174,7 +174,7 @@ void arch_init_memory(void) { extern void subarch_init_memory(struct domain *); - unsigned long i, j, pfn, nr_pfns; + unsigned long i, pfn, rstart_pfn, rend_pfn; struct pfn_info *page; memset(percpu_info, 0, sizeof(percpu_info)); @@ -206,25 +206,26 @@ void arch_init_memory(void) page_set_owner(page, dom_io); } - /* Any non-RAM areas in the e820 map are considered to be for I/O. */ - for ( i = 0; i < e820.nr_map; i++ ) + /* Any areas not specified as RAM by the e820 map are considered I/O. */ + for ( i = 0, pfn = 0; i < e820.nr_map; i++ ) { - if ( e820.map[i].type == E820_RAM ) + if ( e820.map[i].type != E820_RAM ) continue; - pfn = e820.map[i].addr >> PAGE_SHIFT; - nr_pfns = (e820.map[i].size + - (e820.map[i].addr & ~PAGE_MASK) + - ~PAGE_MASK) >> PAGE_SHIFT; - for ( j = 0; j < nr_pfns; j++ ) + /* Every page from cursor to start of next RAM region is I/O. */ + rstart_pfn = PFN_UP(e820.map[i].addr); + rend_pfn = PFN_DOWN(e820.map[i].addr + e820.map[i].size); + while ( pfn < rstart_pfn ) { - if ( !pfn_valid(pfn+j) ) - continue; - page = &frame_table[pfn+j]; + BUG_ON(!pfn_valid(pfn)); + page = &frame_table[pfn++]; page->count_info = PGC_allocated | 1; page->u.inuse.type_info = PGT_writable_page | PGT_validated | 1; page_set_owner(page, dom_io); } + /* Skip the RAM region. */ + pfn = rend_pfn; } + BUG_ON(pfn != max_page); subarch_init_memory(dom_xen); } diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 644dc7d3e9..b30df4de15 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -582,8 +582,8 @@ void __init __start_xen(multiboot_info_t *mbi) { /* Calculate page-frame range, discarding partial frames. */ unsigned long start, end; - start = (e820.map[i].addr + PAGE_SIZE - 1) >> PAGE_SHIFT; - end = (e820.map[i].addr + e820.map[i].size) >> PAGE_SHIFT; + start = PFN_UP(e820.map[i].addr); + end = PFN_DOWN(e820.map[i].addr + e820.map[i].size); /* Clip the range to above 64MB. */ if ( end < (64UL << (20-PAGE_SHIFT)) ) continue; -- 2.30.2